package com.collectplus.express.self;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.collectplus.express.R;
import com.collectplus.express.model.ExpressCompanyBean;

import java.util.ArrayList;

import droid.frame.activity.base.BaseAdapterWithImage;

/**
 * 选择快递公司适配器
 * Created by lidandan on 2018/4/16.
 */

public class SelfExpressCompanyAdapter extends BaseAdapterWithImage<ExpressCompanyBean> {
    public SelfExpressCompanyAdapter(ArrayList<ExpressCompanyBean> items, Activity context, ViewGroup listView) {
        super(items, context, listView);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.self_express_company_item, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.mExpressCompanyLogo = (ImageView) convertView.findViewById(R.id.express_company_logo);
            viewHolder.mExpressCompanyTV = (TextView) convertView.findViewById(R.id.express_company_tv);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        ExpressCompanyBean items = getItem(position);
        showImage(items.getLogo(), viewHolder.mExpressCompanyLogo, null);
        viewHolder.mExpressCompanyTV.setText(items.getName());
        return convertView;
    }

    class ViewHolder {
        private ImageView mExpressCompanyLogo;
        private TextView mExpressCompanyTV;
    }
}
